package com.tianma315.admin.product.view;

import com.tianma315.admin.common.base.BaseController;
import com.tianma315.admin.product.domain.Product;
import com.tianma315.admin.product.service.ProductService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

//                   _ooOoo_
//                  o8888888o
//                  88" . "88
//                  (| -_- |)
//                  O\  =  /O
//               ____/`---'\____
//             .'  \\|     |//  `.
//            /  \\|||  :  |||//  \
//           /  _||||| -:- |||||-  \
//           |   | \\\  -  /// |   |
//           | \_|  ''\---/''  |   |
//           \  .-\__  `-`  ___/-. /
//         ___`. .'  /--.--\  `. . __
//      ."" '<  `.___\_<|>_/___.'  >'"".
//     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
//     \  \ `-.   \_ __\ /__ _/   .-` /  /
//======`-.____`-.___\_____/___.-`____.-'======
//                   `=---='
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//         佛祖保佑       永无BUG

/**
 * Description
 * <p>
 * Created by zcm on 2019/5/25.
 */
@Controller
@RequestMapping("/product/view")
public class ProductViewController extends BaseController {

    @Autowired
    private ProductService productService;

    @RequestMapping("/list")
    @RequiresPermissions("product:list")
    ModelAndView list() {
        ModelAndView view = new ModelAndView("product/list");
        return view;
    }


    @RequestMapping("/add")
    @RequiresPermissions("product:add")
    ModelAndView add() {
        ModelAndView view = new ModelAndView("product/add");
        return view;
    }

    @RequestMapping("/edit/{product_id}")
    @RequiresPermissions("product:edit")
    ModelAndView edit(@PathVariable long product_id) {
        Product product = productService.getById(product_id);
        ModelAndView view = new ModelAndView("product/edit");
        view.addObject("product", product);
        return view;
    }


}
